﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyWeb.Model.ScheduledTask
{
    /// <summary>
    /// 任务
    /// </summary>
    [Description("任务表")]
    [SugarTable("JobsModel")]
    public class JobsModel
    {
        /// <summary>
        /// 主键Id
        /// </summary>
        [Description("主键Id")]
        [SugarColumn(IsPrimaryKey = true, IsNullable = false)]
        public long Id { get; set; }
        /// <summary>
        /// 执行开始时间
        /// </summary>
        [Description("执行开始时间")]
        public DateTime BeginDate { get; set; }
        /// <summary>
        /// 执行结束时间
        /// </summary>
        [Description("结束时间")]
        public DateTime EndDate { get; set; }
        /// <summary>
        /// 执行响应消息
        /// </summary>
        [Description("执行响应消息")]
        public string Msg { get; set; } = string.Empty;

        /// <summary>
        /// 任务名
        /// </summary>
        [Description("任务名")]
        public string TaskName { get; set; } = string.Empty;
        /// <summary>
        /// 分组名
        /// </summary>
        [Description("分组名")]
        public string GroupName { get; set; } = string.Empty;
        /// <summary>
        /// 间隔时间
        /// </summary>
        [Description("间隔时间")]
        public string Interval { get; set; } = string.Empty;
        /// <summary>
        /// 任务描述
        /// </summary>
        [Description("任务描述")]
        public string Describe { get; set; } = string.Empty;
        /// <summary>
        /// 最近一次运行时间
        /// </summary>
        [Description("最近一次运行时间")]
        public DateTime? LastRunTime { get; set; }
        /// <summary>
        /// 运行状态
        /// </summary>
        [Description("运行状态")]
        public int Status { get; set; }
        /// <summary>
        /// 任务类型(1.DLL类型,2.API类型)
        /// </summary>
        [Description("任务类型(1.DLL类型,2.API类型)")]
        public int TaskType { get; set; }

        #region Api类型专用参数
        /// <summary>
        /// 调用的API地址
        /// </summary>
        [Description("调用的API地址")]
        public string ApiUrl { get; set; } = string.Empty;
        /// <summary>
        /// API访问类型(API类型)
        /// </summary>
        [Description("API访问类型(API类型)")]
        public string ApiRequestType { get; set; } = string.Empty;
        /// <summary>
        /// Api头部参数JSON(API类型)
        /// </summary>
        /// 
        [Description("Api头部参数JSON(API类型)")]
        public string ApiHeader { get; set; } = string.Empty;
        /// <summary>
        /// ApiBody参数JSON(API类型)
        /// </summary>
        /// 
        [Description("ApiBody参数JSON(API类型)")]
        public string ApiBody { get; set; } = string.Empty;
        /// <summary>
        /// 请求参数【键值JSON】
        /// </summary>
        /// 
        [Description("请求参数")]
        public string Parameter { get; set; } = string.Empty;
        #endregion

        #region DLL类型专用参数
        /// <summary>
        /// DLL名称
        /// </summary>
        /// 
        [Description("DLL名称")]
        public string DllName { get; set; } = string.Empty;
        /// <summary>
        /// DLL类型名
        /// </summary>
        /// 
        [Description("DLL类型名")]
        public string DllClassName { get; set; } = string.Empty;

        /// <summary>
        /// Dll方法名
        /// </summary>
        /// 
        [Description("Dll方法名")]
        public string DllActionName { get; set; } = string.Empty;
        #endregion
    }

    /// <summary>
    /// 
    /// </summary>
    public enum JobState
    {
        /// <summary>
        /// 新增
        /// </summary>
        新增 = 1,
        /// <summary>
        /// 删除
        /// </summary>
        删除 = 2,
        /// <summary>
        /// 修改
        /// </summary>
        修改 = 3,
        /// <summary>
        /// 暂停
        /// </summary>
        暂停 = 4,
        /// <summary>
        /// 停止
        /// </summary>
        停止 = 5,
        /// <summary>
        /// 开启
        /// </summary>
        开启 = 6,
        /// <summary>
        /// 立即执行
        /// </summary>
        立即执行 = 7
    }
}
